﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

using Sharp.Infrastructure;

namespace Sharp.WebBooter
{
    public static class ControllerExtensions
    {
        public static ActionResult Store<T>(this Controller controller, PagedResult<T> data)
        {

            return new ContentResult()
            {
                Content = data.ToReturnedData().ToJson(),
                ContentEncoding = Encoding.UTF8,
                ContentType = "application/json"
            };
        }
        /// <summary>
        /// 使用Json.Net返回json数据
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static ActionResult JsonNet(this Controller controller, object data)
        {
            return new ContentResult()
            {
                Content = data.ToJson(),
                ContentEncoding = Encoding.UTF8,
                ContentType = "application/json"
            };
        }
    }
}